def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def next_prime_number(num):
    number_words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
    num_str = num.lower()
    num_list = num_str.split()
    
    if len(num_list) != 3:
        print("Wrong input")
        return
    
    number = ""
    for word in num_list:
        if word in number_words:
            number += str(number_words.index(word))
        else:
            print("Wrong input")
            return
    
    number = int(number)
    
    while True:
        if is_prime(number):
            print(number)
            return
        number += 1

input_str = input("Введите три слова: ")
next_prime_number(input_str)